<!DOCTYPE html>
<html lang="en">
<?php
include_once("u_checkLogin.php");
include_once("u_getLoginInfo.php");

if (!isset($_GET['id'])) {
    echo "<script>alert('参数错误');location.href='user_index.php';</script>";
    exit();
}
?>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="../public/pic/f.png" type="image/x-icon">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>文章查看</title>
    <link rel="stylesheet" href="../public/css/bootstrap.min.css">
    <link rel="stylesheet" href="../public/css/user_public.css">
    <script src="../public/js/bootstrap.bundle.min.js"></script>
    <link rel="stylesheet" href="css/user_Tips.css">
</head>

<body>
    <!-- 头部信息开始 -->
    <header>
        <nav class="nav-top">
            <!-- 网站logo -->
            <div class="logo">
                <img src="../public/pic/logo-h-w.png" alt="动物家宠物医院">
            </div>
            <!-- 登录者信息 -->
            <div class="user-info">
                <div class="user-info-con">
                    <span>现在时间：<span id="nowtime"></span></span>
                    <script src="../public/js/getnowtime.js"></script>
                    <br>
                    <span>当前登录：<name>
                            <?php echo $userName; ?>
                        </name></span>
                </div>
                <a href="u_logout.php">点我退出</a>
            </div>
        </nav>
    </header>
    <!-- 头部信息结束 -->

    <!-- 主要内容开始 -->
    <main>
        <a href="user_index.php"><button type="button" class="btn btn-primary">返回</button></a>
        <div class="tips-div">
            <?php
            include_once("conn.php");
            $id = $_GET['id'];
            $select_tips = "SELECT * FROM tips_infos WHERE tips_ID = '" . $id . "'";
            if ($result = mysqli_query($connect_DB, $select_tips)) {
                $row = mysqli_fetch_object($result);
                echo "<h2 class='title'>" . $row->tips_Title . "<h2>";
                echo "<p class='time'>" . $row->tips_Date . " | 当前点击量：".$row->tips_Click."</p>";
                echo "<br>";
                echo $row->tips_Content;
            }else{
                echo "<script>alert('查询文章信息失败!');location.href='user_index.php';</script>";
                exit();
            }

            $update = "UPDATE tips_infos SET tips_Click = tips_Click+1 WHERE tips_ID = '" . $id . "'";
            mysqli_query($connect_DB, $update);

            ?>
        </div>
    </main>
    <!-- 主要内容结束 -->

    <!-- 底部开始 -->
    <footer>
        <p>&copy; 2025 ANIMAL HOME PET HOSPITAL. All rights reserved.</p>
    </footer>
    <!-- 底部结束 -->
</body>

</html>